
#pragma once

using namespace System::Collections::Generic;
using namespace System::IO;
using namespace System::Drawing;

ref class Bridge;

ref struct Wire
{
	static Pen^ wirePen = gcnew Pen (Color::Brown, 2);
	static Pen^ forwardingWirePen = gcnew Pen (Color::Green, 4);
	static Pen^ tempWirePen = gcnew Pen (Color::Blue, 2);

	literal float GrabHandleRectSize = 6;

	ref struct Point abstract
	{
		virtual PointF GetCoords () abstract;
		virtual void Serialize (BinaryWriter^ bw) abstract;
	};

	ref struct PortPoint : Point
	{
		Bridge^ bridge;
		int portIndex; 

		PortPoint (Bridge^ bridge, int portIndex);
		PortPoint (BinaryReader^ br);

		virtual PointF GetCoords () override;
		virtual void Serialize (BinaryWriter^ bw) override;
	};

	ref struct FreePoint : Point
	{
		float x;
		float y;

		FreePoint (float x, float y);
		FreePoint (BinaryReader^ br);

		virtual PointF GetCoords () override;
		virtual void Serialize (BinaryWriter^ bw) override;
	};

//	bool connected;
	List<Point^>^ points;

	Wire (Bridge^ startBridge, int startPortIndex, Bridge^ endBridge, int endPortIndex);
	Wire (BinaryReader^ br);

//	void AttachPointToPort (int pointIndex, Bridge^ bridge, int portIndex);
//	void DetachPointFromPort (int pointIndex);

	property Point^ FirstPoint { Point^ get () { return points [0]; } }
	property Point^ LastPoint { Point^ get () { return points [points->Count - 1]; } }

	void Paint (Graphics^ g);

	void Serialize (BinaryWriter^ bw);
};
